from fabric.api import run, env, local, put, cd, lcd

env.hosts = ['xxx']
env.user = 'root'
env.port = 22
# env.password = 'xxx'
env.key_filename = '~/.ssh/id_rsa'

path = 'xxx'
filename = 'fastdev-java-0.0.1.jar'


# 启动（打包，上传，构建，启动，打印日志）
def startup():
    with lcd("../"):
        package()
        with cd(path):
            put('target/' + filename, path + '/jar/')
            run('./build.sh')
            run('./startup.sh')


# 查看日志
def log():
    with cd(path):
        run('./taillog.sh')


# 查看日志
def lesslog():
    with cd(path):
        run('./lesslog.sh')


# 进入容器
def entryin():
    with cd(path):
        run('./entryin.sh')


# 打包
def package():
    local('mvn clean package -DskipTests')
